Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

deThread.hpp

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////
00002 /// @file deThread.hpp
00003 ///
00004 /// @brief 
00005 ///
00006 /// @author trajar
00007 ///
00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
00009 /// contents of this file is subject to the Destiny3D Member License which
00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
00011 ///
00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
00014 /// for any particular purpose.
00015 ///
00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
00017 ///
00018 /// <hr>
00019 ///                                 Change History
00020 /// <hr>
00021 ///
00022 /// @date Jun 2002
00023 /// @author trajar
00024 /// @remarks Creation
00025 ///
00026 ///////////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef _DETHREAD_HPP
00029 #define _DETHREAD_HPP
00030 
00031 #ifndef     _DENET_HPP
00032  #include   "deNet.hpp"
00033 #endif
00034 
00035 #ifndef     _DESYNCHOBJECT_HPP
00036  #include   "deSynchObject.hpp"
00037 #endif
00038 
00039 #include <WINDOWS.H>
00040 
00041 class deThreadPool;
00042 
00043 class DENET_API deThread
00044 {
00045 public:
00046 
00047         //--------------------------------------------------------------------
00048         // enum eStatus - Thread statues
00049         //--------------------------------------------------------------------
00050         enum eStatus
00051         {
00052             STATUS_UNKNOWN  = -3,
00053             STATUS_NONE     = -2,
00054             STATUS_SLEEP    = -1,
00055             STATUS_RUN      = 0,
00056             STATUS_WAKEUP,          
00057             STATUS_STOP,
00058             STATUS_DEAD,
00059             STATUS_MAX_NUMBER,
00060         };
00061 
00062         typedef DWORD (* ActiveProcess)( void * );
00063 
00064         deThread();
00065         virtual ~deThread();
00066 
00067         bool        Start ( void );
00068         DWORD       Stop  ( bool bForceKill = false );
00069         void        AttachProcess( ActiveProcess ptr, void * param );
00070         void        DetachProcess(void);
00071         bool        Sleep ( void );
00072         bool        Wakeup( void );
00073 
00074         DWORD       GetExitCode();
00075         eStatus     GetStatus(void) const;
00076         
00077 protected:
00078 
00079         //--------------------------------------------------------------------
00080         // DWORD Run( void * )
00081         //--------------------------------------------------------------------
00082         static DWORD WINAPI Run( LPVOID param );
00083     
00084 protected:
00085 
00086         //--------------------------------------------------------------------
00087         // struct ThreadContext
00088         //--------------------------------------------------------------------
00089         class ThreadContext
00090         {
00091             friend class deThread;
00092         public:
00093 
00094             ThreadContext(void) : m_pParent(NULL), m_ProcessParam(NULL), m_AttachedProcess(NULL)            { }
00095             virtual ~ThreadContext(void)    { }
00096 
00097         protected:
00098 
00099             HANDLE          m_hThread;                      //  The Thread Handle
00100             DWORD           m_dwTID;                        //  The Thread ID
00101             deThread *      m_pParent;                      //  The this pointer of the parent CThread object
00102             DWORD           m_dwExitCode;                   //  The Exit Code of the thread
00103             HANDLE          m_Events[STATUS_MAX_NUMBER];
00104             HANDLE          m_ProcessChangeEvent;
00105             void     *      m_ProcessParam;
00106             ActiveProcess   m_AttachedProcess;
00107         };
00108 
00109         static deSynchObject    m_SynchObject;
00110         eStatus                 m_Status;
00111         ThreadContext           m_ThreadCtx;    //  The Thread Context member
00112         LPTHREAD_START_ROUTINE  m_pThreadFunc;  //  The Worker Thread Function Pointer
00113 };
00114 
00115 #endif

Generated on Mon Sep 12 19:58:40 2005 for Destiny3D by doxygen1.3-rc3